import request from '@/utils/request'

// 注册用户
export const userRegisterServiceApi = ({ username, password, repassword }) => {
  // 不要忘记写return
  return request.post('/api/reg', { username, password, repassword })
}

// 登录
export const userLoginServiceApi = ({ username, password }) => {
  return request.post('/api/login', { username, password })
}

// 获取用户个人信息
export const userGetInfoServiceApi = () => request.get('/my/userinfo')

// 更新用户信息
export const updateUserInfoApi = (data) => request.put('/my/userinfo', data)

// 更新用户头像
export const updateAvatarApi = (avatar) =>
  request.patch('/my/update/avatar', { avatar })

// 更新密码信息
export const userUpdatePassApi = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
